<?php

namespace App\Providers;

use App\Contract\SktContract;
use App\Interfaces\BillNotifiterInterface;
use App\Interfaces\EmailBillNotifier;
use App\Logic\OrderProcess;
use App\Services\SktService;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\ServiceProvider;

class AppServiceProvider extends ServiceProvider
{
    /**
     * Register any application services.
     *
     * @return void
     */
    public function register()
    {
        //

        $this->app->bind('OrderProcessor',function($app){

            return new OrderProcess(
                $app->make('BillerInterface'),
                $app->make('OrderRepository'),
                [
                    $app->make('RecentOrderValidator'),
                    $app->make('SuspendedAccountValidator')
                ]
            );
        });
    }

    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {
        //
        Schema::defaultStringLength(191);
        $this->app->bind(BillNotifiterInterface::class, function ($app) {
            return new   EmailBillNotifier();
        });


//        //使用singleton 绑定单例
//        $this->app->singleton('skt', function () {
//            return new SktService();
//        });
        //使用bind绑定接口
        $this->app->bind('App\Contracts\SktContract', function () {
            return new SktService();
        });


    }
}
